﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using nplJobsCommon.Common;

namespace nplJobsDAL.Select
{
    public class SelectCareerLevel : DataAccessBase
    {
        public SelectCareerLevel()
        {
            StoredProcedureName = StoredProcedure.Name.spSelectCareerLevel.ToString();
        }

        #region GetCareerLevel
        public List<CareerLevel> GetCareerLevel()
        {
            DataBaseHelper dbHelper;
            DataSet dsCareerLevel;

            try
            {
                dbHelper = new DataBaseHelper(StoredProcedureName);
                dsCareerLevel = dbHelper.Run(base.ConnectionString);
                return GetList(dsCareerLevel);
            }
            catch (Exception)
            {

                throw;
            }
        }
        #endregion

        #region GetList
        private List<CareerLevel> GetList(DataSet dsCareerLevel)
        {
            List<CareerLevel> careerLevels;
            try
            {
                careerLevels = (from n in dsCareerLevel.Tables[0].AsEnumerable()
                                select new CareerLevel
                                   {
                                       ID = n.Field<int>("ID"),
                                       Level = n.Field<string>("CareerLevel")
                                   }).ToList();

                return careerLevels;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message.ToString());
            }
            finally { }
        }
        #endregion
    }
}


